{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "One Dot Per Zipcode\n",
    "-----------------------\n",
    "This example shows a geographical plot with one dot per zipcode.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# category: geographic\n",
    "\n",
    "import altair as alt\n",
    "alt.data_transformers.enable('json')\n",
    "from altair.expr import datum, substring\n",
    "from vega_datasets import data\n",
    "\n",
    "zipcodes = data.zipcodes.url\n",
    "\n",
    "alt.Chart(zipcodes).mark_circle(size=3).encode(\n",
    "    longitude='longitude:Q',\n",
    "    latitude='latitude:Q',\n",
    "    color='digit:N'\n",
    ").project(\n",
    "    type='albersUsa'\n",
    ").properties(\n",
    "    width=650,\n",
    "    height=400\n",
    ").transform_calculate(\n",
    "    \"digit\", substring(datum.zip_code, 0, 1)\n",
    ")\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "env": {},
   "interrupt_mode": "signal",
   "language": "python",
   "metadata": {},
   "name": "python3"
  },
  "language": "python"
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
